<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>表单域修饰符</title>
    <style>
      .bule {
        background-color: pink;
      }
    </style>
  </head>
  <body>
    <pre>
   参数不能重复binding
        全局指令：在所有组件中都可以使用
        局部指令：在当前组件可以使用
      </pre
    >
    <div class="box">
      <form action="">
        <label for="user">用户名</label>
        <input type="text" id="user" v-bgc="{color:'purple'}" v-focus />
      </form>
    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script>
      Vue.directive('focus', {}) //局部自定义属性

      new Vue({
        el: '.box',
        data: {
          blue: 'blue',
        },
        methods: {},
        //局部指令
        directives: {
          focus: {
            bind: function (el) {
              el.focus()
            },
          },
          bgc: {
            inserted: function (el, paramas) {
              console.log(paramas)
              el.style.backgroundColor = paramas.value.color
            },
          },
        },
      })
    </script>
  </body>
</html>
